<template>
  <div>
    <search-form
      :search-config="searchConfig"
      :label-width="150"
      @clear="clearSearch"
      @search="handleSearch"
    />
    <c-permission-tabs v-model="activeType" code="tab">
      <el-tab-pane label="全部" name="all" opt-code="all">
        <List :active-type="activeType" :serach-filters="serachFilters" type="all" />
      </el-tab-pane>
      <el-tab-pane label="待分配" name="waitAllot" opt-code="allot">
        <List :active-type="activeType" :serach-filters="serachFilters" type="waitAllot" />
      </el-tab-pane>
      <el-tab-pane label="待处理" name="waitHandle" opt-code="deal">
        <List :active-type="activeType" :serach-filters="serachFilters" type="waitHandle" />
      </el-tab-pane>
      <el-tab-pane label="待审核" name="waitAudit" opt-code="audit">
        <List :active-type="activeType" :serach-filters="serachFilters" type="waitAudit" />
      </el-tab-pane>
      <el-tab-pane label="待终止" name="termination" opt-code="termination">
        <List :active-type="activeType" :serach-filters="serachFilters" type="termination" />
      </el-tab-pane>
      <el-tab-pane label="待审批" name="pending" opt-code="pending">
        <List :active-type="activeType" :serach-filters="serachFilters" type="pending" />
      </el-tab-pane>
    </c-permission-tabs>
  </div>
</template>
<script>
import List from './components/List'
export default {
  name: 'ShopDesignTaskManagement',
  components: {
    List
  },
  data() {
    return {
      activeType: '',
      searchConfig: [
        {
          type: 'select',
          prop: 'taskType',
          label: '任务类型',
          value: '',
          placeholder: '任务类型',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/TASK_TYPE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'state',
          label: '任务进度',
          value: '',
          placeholder: '任务进度',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/DESIGN_TASK_STATE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          label: '任务编号',
          prop: 'designTaskCode',
          type: 'text',
          value: '',
          placeholder: '任务编号'
        },
        {
          label: '门店',
          prop: 'shopCode',
          type: 'dialog',
          value: '',
          placeholder: '门店',
          config: {
            requestMethod: 'post',
            paramField: 'paramKeyword', // 远程搜索参数名
            defaultProps: {
              label: 'name',
              value: 'code'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '门店',
            interfacePath:
              '/select-service/api/v1/shop/page',
            setting: [
              { prop: 'code', title: '编码' },
              { prop: 'name', title: '名称' }
            ]
          }
        },
        {
          label: '所属客户',
          prop: 'clientCode',
          type: 'dialog',
          value: '',
          placeholder: '所属客户',
          config: {
            requestMethod: 'post',
            remoteUrl: '/select-service/api/v1/customer/page',
            paramField: 'keyWord', // 远程搜索参数名
            defaultProps: {
              label: 'name',
              value: 'code'
            },
            selectData: [],
            apiHeader: {
              'permission-code': 'designtaskmanagement', // 页面权限编码
              'Permission-App': 'slm'
            }
          },
          dialogConfig: {
            title: '所属客户',
            interfacePath: '/select-service/api/v1/customer/page',
            setting: [{ prop: 'code', title: '编码' }, { prop: 'name', title: '名称' }],
            pageFlag: true
          }
        },
        {
          label: '所属办事处',
          prop: 'officeCode',
          type: 'dialog',
          value: '',
          placeholder: '所属办事处',
          config: {
            requestMethod: 'post', // 远程搜索请求方式:post,get;默认为get
            remote: true, // 远程搜索API地址
            paramField: 'keyWord', // 远程搜索参数名
            defaultProps: {
              label: 'name',
              value: 'code'
            }, // api返回数据默认字段
            multiple: false,
            selectData: []
          },
          dialogConfig: {
            title: '办事处',
            interfacePath:
              '/select-service/api/v1/organization/page',
            filtersRaw: [{ 'id': 'isOffice', 'property': 'isOffice', 'value': '1', 'operator': '=' }],
            setting: [
              { prop: 'code', title: '编码' },
              { prop: 'name', title: '名称' }
            ]
          }
        },
        {
          type: 'dialog',
          prop: 'constCode',
          label: '门店建设项目号',
          value: '',
          placeholder: '门店建设项目号',
          config: {
            requestMethod: 'post',
            defaultProps: {
              label: 'constCode',
              value: 'constCode'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '门店建设项目号',
            interfacePath:
              '/slm-admin/api/v1/shopConstruct/allPage',
            setting: [
              { prop: 'constCode', title: '编码' },
              { prop: 'shopName', title: '门店' }
            ]
          }
        },
        {
          label: '设计单位',
          prop: 'designUnitCode',
          type: 'dialog',
          value: '',
          placeholder: '设计单位',
          config: {
            requestMethod: 'get',
            // paramField: 'paramKeyword', // 远程搜索参数名
            defaultProps: {
              label: 'orgName',
              value: 'orgCode'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '设计单位',
            method: 'get',
            interfacePath:
              '/slm-admin/api/v1/user/orgTreeByType?type=9',
            setting: [
              { prop: 'orgCode', title: '编码' },
              { prop: 'orgName', title: '名称' }
            ]
          }
        },
        { label: '任务分配时间', prop: 'distributeTime', type: 'date', value: '', placeholder: '请选择' },
        {
          type: 'select',
          prop: 'dataSource',
          label: '数据来源',
          value: '',
          placeholder: '数据来源',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/DATA_SOURCE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        }
      ],
      serachFilters: []
    }
  },
  methods: {
    clearSearch(data) {
      this.serachFilters = []
    },
    // 获取搜索条件
    handleSearch(data) {
      this.serachFilters = data.filtersRaw
    }
  }
}
</script>
